<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <ul id="container"></ul>
    <script>
        let ul = document.getElementById('container');
        let total = 100000;
        let once = 20; // 每次20条
        let page = total/once;
        let index = 0;

        function loop(curTotal, curIndex) {
            if (curTotal <= 0) {
                return;
            }
            let pageCount = Math.min(curTotal, once);
            // 宏任务 异步
            setTimeout(() => {
                for (let i = 0; i < pageCount; i++) {
                    let li = document.createElement('li');
                    li.innerText = curIndex + i + ':' + (Math.random() * total);
                    ul.appendChild(li);
                }
                loop(curTotal - pageCount, curIndex + pageCount);
            }, 0);
        }
        loop(total, index);
    </script>
</body>
</html>